<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    //js上两种常见的自定义对象方式
    let person={
        name:"zhangsan",
        address:"重庆",
        age:18,
        eat:function(){
            console.log("我们在"+this.address);
        }
    }
    person.eat();
    console.log(person.age);
    console.log(person.name);

    
   class student{
    //构造函数
        constructor(name,age){
            this.age=age;
            this.name=name;
        }
    }
    let xiaoming=new student("小明",19);
    console.log(xiaoming.age);
    console.log(xiaoming.name);
</script>
</html>